import React, { Component } from 'react';
import {
  StyleSheet,
  Text,
  View,
  ScrollView,
  Image,
  TextInput,
  TouchableOpacity,
  Platform,
  DeviceEventEmitter,
  NativeAppEventEmitter,
  Dimensions
} from 'react-native';

import * as config from '../../constants/apiConfig';
import styles from './editOrderStyle';
import helper from '../util/helper';
import _ from 'lodash';
import api from '../../services/api';
import Toast from 'react-native-sk-toast';
import DatePicker from 'react-native-datepicker';
import moment from 'moment';
import ToastTip from '../global/ToastTip';
import LoadingTip from '../global/LoadingTip';
import ImagePicker from 'react-native-image-picker';
import Touch from '../global/Touch';
import DeviceStorage from '../global/DeviceStorage';

import KeyboardAwareScrollView from '../global/keyboardScrollView/KeyboardAwareScrollView';
import { Navigation } from '../global/navigation/index';

const SAVE_ORDER_KEY = "@order@express";
const {width: deviceWidth, height: deviceHeight} = Dimensions.get('window');
class EditExpressOrder extends Component {
    constructor(props) {
		super(props);
        let {data, source} = this.props;
        let serviceContentMap = {
            '送至服务中心':0,
            '从服务中心送至业主家中':1,
            '快递柜取并送至业主家中':2
        };

        let act = [0,0,0];
        if(source == 'edit'){
            act[serviceContentMap[data.express_service_content]] = 1;
        }else {
            act = [1,0,0];
        }

		this.state = {
            isLoading: true,
			isRefreshing: false,
			currentPage: 1,
            activeService:act,
            addrContent:false,
            send_phone: source=='edit'?data.user_phone:(this.props.userPhone?this.props.userPhone:''),
            remarks:source=='edit'?(data.remarks||''):'',
            date: source=='edit'?moment(data.service_time).format('YYYY-MM-DD HH:mm'):moment().add(30,'minutes').format('YYYY-MM-DD HH:mm'),
            disableUpload:false,
            pictureFileUriList:[],
            pictureFileList:[],
            orderCreateSuccess:false,
		};

		// this.props.navigator.setOnNavigatorEvent(this._onNavigatorEvent.bind(this));
	}

    async _submitAction(){
        let {source, data} = this.props;

        let serviceContentMapS = {
            0:'送至服务中心',
            1:'从服务中心送至业主家中',
            2:'快递柜取并送至业主家中'
        };

        // let {date, weixin, send_phone,to_address ,service_time, obj_name, obj_price,remarks, activeService,fileUri,fileData} = this.state;
        let {date, weixin, send_phone,to_address ,service_time, obj_name, obj_price,remarks, activeService,pictureFileList,ownerInfo} = this.state;
        let req_data = {
            from_address:'',
            to_address:to_address||(source=='edit'?data.to_address:''),
            buy_address: '',
            service_type: 'express',
            service_time: date||(source=='edit'?helper.returnTimeToStr(data.service_time):''),
            obj_name: '',
            obj_price: 0,
            phone: '',
            user_phone: send_phone,
            remarks:remarks,
            express_service_content: serviceContentMapS[_.findIndex(activeService, function(o) { return o == 1;})],
            lockkey_service_content:'',
            other_service_content:'',
            obj_image:'',
            start_location:'',
            dest_location: '',
            weixin: weixin||(source=='edit'?data.weixin:''),
            remarkImageList:[],
            ownerInfo:ownerInfo,
        };

        if(source == 'edit'){
            req_data.id = data.id;
        }else{//创建时
            req_data.status = 1;
        }

        // if(!req_data.weixin){
        //     this.refs.toast.show('请输入收件人微信号');
        //     return;
        // }
        //
        // if(req_data.weixin.length>16){
        //     this.refs.toast.show('收件人微信号不能超过16个字符');
        //     return;
        // }

        if(!req_data.user_phone){
            this.refs.toast.show('请输入收件人手机号');
            return;
        }

        if(!/^1[0-9]{10}$/.test(req_data.user_phone)){
            this.refs.toast.show('请输入正确的手机号');
            return;
        }

        if(!req_data.to_address){
            this.refs.toast.show('请输入收件人地址');
            return;
        }

        if(req_data.to_address.length>70){
            this.refs.toast.show('收件人地址不超过70个字符');
            return;
        }

        if(moment(req_data.service_time)-moment()<0){
            this.refs.toast.show('输入的时间需大于当前时间');
            return;
        }

        if(req_data.remarks.length>200){
            this.refs.toast.show('备注信息不能超过200个字符');
            return;
        }
        for (var i = 0; i < pictureFileList.length; i++) {
            req_data.remarkImageList.push(pictureFileList[i].id)
        }
        console.log('test====editExpressOrder===submit',req_data);

        if(source != 'edit'){
            this.props.navigator.push({
                title: "确认提交订单",
    			screen: 'housekeeperapp.orderconfirm',
                backButtonTitle:'',
    			passProps: {
    				order_detail:req_data,
                    order_phone: this.props.userPhone,
                    // fileUri:this.state.fileUri,
                    isPay:this.state.isPay,
                    serviceFee:this.state.serviceFee,
    			},
                navigatorStyle:{
                    tabBarHidden: true,
                    navBarTextColor: 'white',
                	navBarButtonColor: 'white',
                	navBarBackgroundColor: '#EA5404',
                    statusBarColor: '#EA5404',
                    navBarTitleTextCentered: true,
                    topBarElevationShadowEnabled:false
                },
                navigatorButtons: {
                    leftButtons:[
                        {
                            id: 'back',
                            icon: require("../../../img/hk_back_icon.png")
                        }
                    ]
                }
    		});
            return;
        }

        this.setState({loadingShow:true});
        // req_data = {...req_data,remarkImage:fileData?fileData:''};
        console.log('test------------req_data',req_data);
        // let url = (source == 'edit'? :'/order/createorder');
        let res = await api.post('/order/updateorder',req_data);
        if(res.cd == 1){
            this.refs.toast.show(res.msg);
        }else{
            if(res.data){
                this.setState({loadingShow:false});

                Toast.bottom("编辑成功");
                setTimeout(() =>{
                    this.props.navigator.pop();
                    let Emitter = Platform.OS === 'android' ? DeviceEventEmitter : NativeAppEventEmitter;
                    Emitter.emit("order.onload");
                }, 500);
            }
        }

    }

    async _showUserAddrBtn(text){
        let phone = text || this.state.send_phone;
        console.log("$$$$$", phone);

        if(phone){
            let res = await api.post('/account/findUserByPhone',{phone});
            console.log('_showUserAddrBtn',res);
            if(res && res.data){
                this.setState({addrContent:res.data.homeAddress,ownerInfo:res.data});
            }
        }
    }

    _addressAction(){
        let {addrContent} = this.state;
        this.setState({
            to_address: addrContent
        });
    }

    _selectAction(index){
        let temp = [0,0,0];
        temp[index] = 1;
        this.setState({ activeService:temp });
    }

    componentWillMount(){
        let {source,session} = this.props;
        if(source == 'edit'){
            return;
        }
        let {send_phone,date} = this.state;
        if (send_phone && date) {
            this._getServiceFeeInfo(send_phone,date);
        }

        DeviceStorage.get(SAVE_ORDER_KEY).then((origin_data) =>{
            if(origin_data){
                let story = this.props.userPhone?Object.assign({},origin_data,{send_phone: this.props.userPhone}):origin_data;
                this.setState(story);
            }
            // if (session.user.productKey != "LiXiaoShuang") {
                this._showUserAddrBtn();
            // }
            
        });
    }

    async _getServiceFeeInfo(phone,date){


        let res = await api.post('/order/serviceFee',{phone:phone,service_type:'express',serviceTime:date+":00",otherServiceType:''});
        console.log('test-----------dddddssssssssddddd=result',res);
        if (res.cd != 0) {
            return;
        }
        if (res.data) {
            if (res.data.isPay) {//有服务费
                let serviceFee = res.data.serviceFee;
                let totalServiceFee = 0;
                serviceFee.map((item,index) => {
                   totalServiceFee += parseFloat(item.fee);
                })
                this.setState({
                    isPay:res.data.isPay,
                    serviceFee,
                    totalServiceFee,
                })
            }else{
                this.setState({
                    isPay:res.data.isPay,
                    serviceFee:[],
                    totalServiceFee:0,
                })
            }
        }else{
            this.refs.toast.show('获取服务费数据失败'+res.msg)
            this.setState({
                    isPay:false,
                    serviceFee:[],
                    totalServiceFee:0,
                })
        }
        

    }

    _serviceFeeExplain(serviceFeeInfo){
        let {date,send_phone} = this.state;
        Navigation.startServiceFeeExplain({'selectedDate':date+":00",'phone':send_phone,"serviceFeeName":serviceFeeInfo.serviceFeeName,"groupId":serviceFeeInfo.groupId});
    }

    componentDidMount(){

        let Emitter = Platform.OS === 'android' ? DeviceEventEmitter : NativeAppEventEmitter;
        this._subcribOrder = Emitter.addListener('order.create_success', this._orderCreateSuccess.bind(this));
    }

    _orderCreateSuccess(){
        this.setState({
            orderCreateSuccess:true,
        })
    }

    componentWillUnmount(){
        let {source} = this.props;
        let {date, send_phone, to_address, activeService, remarks} = this.state;
        let restory;
        if(this.props.userPhone){
            // send_phone = '';
            restory = { to_address, activeService, remarks};
        }else{
            restory = { send_phone, to_address, activeService, remarks};
        }
        source!='edit' && !this.state.orderCreateSuccess && DeviceStorage.save(SAVE_ORDER_KEY, restory);
        this._subcribOrder && this._subcribOrder.remove();
        
    }

    clearContent(){
        this.setState({
            date: moment().add(30,'minutes').format('YYYY-MM-DD HH:mm'),
            send_phone:'',
            to_address:'',
            activeService:[1,0,0],
            remarks:'',
            pictureFileUriList:[],
            pictureFileList:[],
            isPay:false,
            serviceFee: [],
            totalServiceFee:0,
            ownerInfo:{}
            // fileUri:'',
            // fileData:'',
        });
    }

    _clickImage(index){
        let {pictureFileUriList} = this.state;
        if (pictureFileUriList && pictureFileUriList[index]) {//有图片则预览
            this._previewPicture(pictureFileUriList,index)
            return;
        }
        // this.setState({
        //     disableUpload:true,
        // })
        this._getObj(index);
    }

    _previewPicture(fileUris,index){
        let fileUriString = "";
        for (var i = 0; i < fileUris.length - 1; i++) {
            fileUriString += fileUris[i]+",";
        }
        fileUriString += fileUris[fileUris.length - 1];
        Navigation.startPreviewPictureActivity({"currentIndex":index,"fileUris":fileUriString,"isUrl":true})
    }

    async _getObj(index) {
        var options = {
            title: "上传照片",
            cancelButtonTitle: "取消",
            takePhotoButtonTitle: "拍照",
            chooseFromLibraryButtonTitle: "选择相册",
            permissionDenied: {
                title: "提示",
                text: "没有拍照和获取相册权限",
                reTryTitle: "重试",
                okTitle: "确定"
            },
            mediaType:"photo",
            quality: 0.8,
            maxHeight: parseInt(deviceHeight*2),
            maxWidth: parseInt(deviceWidth*2),
            storageOptions: {
                skipBackup: true,
                path: "images"
            }
        };
        // 照片
        ImagePicker.showImagePicker(options, response => {
            this.setState({
                disableUpload:false,
            })
            // Same code as in above section!
            console.log('test======response',JSON.stringify(response));
            if (response.error) {
                console.log("ImagePicker Error: ", response.error);
            } else {
                if (response.didCancel) {
                    console.log("User cancelled image picker");
                    return;
                }
                this.setState({loadingShow:true});
                console.log('test0000000000',response.uri);
                // let fileData = "data:image/jpeg;base64," + response.data;
                this._postPictureData(response.uri,response.fileName,index)
                // this._completeUpload(response.uri,fileData);
            }
        });

        return false;
    }

    async _postPictureData(fileUri,fileName,index){
        let file = {uri:fileUri,name:fileName,type:'image/jpeg'}
        let result = await api.upload('/file/upload',file,'ORDER')
        console.log('test------------',result);
        if (result.cd == 0) {
            this._completeUpload(result.data.url,index,result.data)
        }else{
            this.setState({
                loadingShow:false,
            })
        }
    }

    _completeUpload(fileUri,index,file){
        let {pictureFileUriList,pictureFileList} = this.state;
        pictureFileUriList[index] = fileUri;
        pictureFileList[index] = file;
        this.setState({
            pictureFileUriList,
            pictureFileList,
            loadingShow:false,
            // fileData:fileData,
        });
    }
    _clearImage(index){
        let {pictureFileUriList,pictureFileList} = this.state;
        // pictureFileUriList[index] = "";
        if (!pictureFileUriList || pictureFileUriList.length == 0) {
            return;
        }
        pictureFileUriList.splice(index,1);
        pictureFileList.splice(index,1);
        // let afterFilterResult = [];
        // for (var i = 0; i < pictureFileUriList.length; i++) {
        //     if (i == index) {
        //         pictureFileUriList[index] = "";
        //         continue;
        //     }
        //     afterFilterResult.push(pictureFileUriList[i]);
        // }
        this.setState({
            pictureFileUriList,
            pictureFileList,
            // fileUri:'',
            // fileData:'',
        })
    }

    async _getNonPayment(){

        if (this.props.showTimes == 0) {//没有展示过

            let {source, data} = this.props;

            // let {date, weixin, send_phone,to_address ,service_time, obj_name, obj_price,remarks, activeService,fileUri,fileData} = this.state;
            let {date, send_phone,to_address ,service_time,remarks} = this.state;
            let req_data = {
                to_address:to_address||(source=='edit'?data.to_address:''),
                service_time: date||(source=='edit'?helper.returnTimeToStr(data.service_time):''),
                user_phone: send_phone,
                remarks:remarks,
            };


            if(!req_data.user_phone){
                this.refs.toast.show('请输入收件人手机号');
                return;
            }

            if(!/^1[0-9]{10}$/.test(req_data.user_phone)){
                this.refs.toast.show('请输入正确的手机号');
                return;
            }

            if(!req_data.to_address){
                this.refs.toast.show('请输入收件人地址');
                return;
            }

            if(req_data.to_address.length>70){
                this.refs.toast.show('收件人地址不超过70个字符');
                return;
            }

            if(moment(req_data.service_time)-moment()<0){
                this.refs.toast.show('输入的时间需大于当前时间');
                return;
            }

            if(req_data.remarks.length>200){
                this.refs.toast.show('备注信息不能超过200个字符');
                return;
            }

            this.setState({loadingShow:true});
            let result = await api.post('/order/getNonPaymentOrder',{phone:send_phone});
            console.log('_getNonPayment',result);
            if (result.cd != 0) {
                Toast.bottom(result.msg);
                return;
            }
            if (result.data && result.data.length != 0) {//有欠费

                this.setState({loadingShow:false},() => {
                    let orderArrearageInfo = result.data[0];
                    this.props.onShowPayNotifyDialog(send_phone,orderArrearageInfo,result.data.length);
                });
                

            }else{//没有欠费
                this.setState({loadingShow:false},() => {
                    this._submitAction();
                });
            }
        }else{
            this.setState({loadingShow:false},() => {
                this._submitAction();
            });
        }
        


    }

    onChangeTextMoney(value,item,index){
        var {serviceFee} = this.state
        let serviceFeeCopy = [];
        var totalServiceFee = 0;
        value = value.replace(/[^\d.]/g,"");  
        value = value.replace(/\.{2,}/g,".");   
        value = value.replace(".","$#$").replace(/\./g,"").replace("$#$","."); 
        value = value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'); 
        if(value.indexOf(".")< 0 && value !=""){
            value= parseFloat(value); 
        } 

        if (value == '') {

            item.fee = 0;
            console.log('onChangeText',serviceFee);
            totalServiceFee = 0;
            for (var i = 0; i < serviceFee.length; i++) {
                totalServiceFee += parseFloat(serviceFee[i].fee)
            }
            console.log('onChangeText=test',totalServiceFee);
            this.setState({
                totalServiceFee,
                serviceFee,
            })
            return;

        }
        item = {...item,fee:value};
        for (var i = 0; i < index; i++) {
            serviceFeeCopy.push(serviceFee[i]);
        }
        serviceFeeCopy.push(item);
        for (var i = index + 1; i < serviceFee.length; i++) {
            serviceFeeCopy.push(serviceFee[i]);
        }
        console.log('onChangeText',item);
        console.log('onChangeText',serviceFeeCopy);
        totalServiceFee = 0;
        for (var i = 0; i < serviceFeeCopy.length; i++) {
            totalServiceFee += parseFloat(serviceFeeCopy[i].fee)
        }
        console.log('onChangeText=test',totalServiceFee);
        this.setState({
            totalServiceFee,
            serviceFee:serviceFeeCopy,
        })
            
    }


    render() {
        let {data, source,session} = this.props;
        let {isPay,serviceFee,pictureFileUriList,ownerInfo,totalServiceFee} = this.state;
        console.log('test====editExpressOrder==render',pictureFileUriList);
        return (
            <View style={styles.wrapper}>
                <KeyboardAwareScrollView style={styles.container} extraScrollHeight={60}>
                    {
                        ownerInfo && ownerInfo.isVip == 1 && isPay?
                            <View style={{height: 40,backgroundColor:'#FFFCED',borderBottomWidth:0.5,borderColor:'#E8E8E8',flexDirection:'row',paddingLeft:15,alignItems:'center'}}>
                                <Text style={{color:'#333333',fontSize:13}}>
                                    服务费用
                                    <Text style={{color:'#FF8200'}}>¥{parseFloat(totalServiceFee).toFixed(2)}</Text>
                                    ，VIP会员每月免费
                                    <Text style={{color:'#FF8200'}}>15</Text>
                                    次，本月剩余
                                    <Text style={{color:'#FF8200'}}>{ownerInfo.keeperServiceLeftCount}</Text>
                                    次
                                </Text>
                                
                            </View>
                        :
                            null
                    }
                    <View style={styles.formContainer}>
                        <View style={styles.formItem}>
                            <Text style={styles.leftText}>收件人</Text>
                            <TextInput
                                value={this.state.send_phone}
                                onChangeText={(text) =>{
                                    let p = text.replace(/ /g, '').substring(0,11);
                                    this.setState({send_phone: p, addrContent:false});
                                    if(p.length == 11){
                                        this._showUserAddrBtn(p);
                                        if (this.state.date) {
                                            this._getServiceFeeInfo(p,this.state.date)
                                        }
                                    }
                                }}
                                style={[styles.itemRight, source=='edit'?{color:"#B5B5B5"}:{}]}
                                editable = {source=='edit'?false:true}
                                maxLength={13}
                                clearButtonMode={'while-editing'}
                                keyboardType={'numeric'}
                                underlineColorAndroid={'#ffffff'}
                                placeholder={'请输入收件人手机号'}
                                placeholderTextColor={'#B5B5B5'}
                            />
                        </View>
                        <View style={styles.formItem}>
                            <Text style={styles.leftText}>收件人地址</Text>
                            <TextInput
                                value={this.state.to_address}
                                defaultValue={source=='edit'?data.to_address:''}
                                onChangeText={(text) =>{this.setState({to_address:text})}}
                                style={styles.itemRight}
                                editable = {true}
                                multiline={Platform.OS=='ios'?false:true}
                                numberOfLines={1}
                                clearButtonMode={'while-editing'}
                                underlineColorAndroid={'#ffffff'}
                                placeholder={'请输入收件人地址'}
                                placeholderTextColor={'#B5B5B5'}
                            />
                            {this.state.addrContent && session.user.productKey != "LiXiaoShuang"?
                            <TouchableOpacity onPress={this._addressAction.bind(this)}>
                                <Text style={styles.addressBtnText}>业主家</Text>
                            </TouchableOpacity>:null}
                        </View>

                        <View style={[styles.formItemSpri,{borderBottomWidth:0}]}>
                            <Text style={styles.leftText}>选择服务内容</Text>
                            <View style={styles.selectContent}>
                                <TouchableOpacity onPress={this._selectAction.bind(this,0)} style={styles.selectBtn}>
                                    <Text style={this.state.activeService[0]?styles.activeText:styles.notActiveText}>送至服务中心</Text>
                                </TouchableOpacity>
                                <TouchableOpacity onPress={this._selectAction.bind(this,1)} style={styles.selectBtn}>
                                    <Text style={this.state.activeService[1]?styles.activeText:styles.notActiveText}>从服务中心送至业主家中</Text>
                                </TouchableOpacity>
                                <TouchableOpacity onPress={this._selectAction.bind(this,2)} style={styles.selectBtn}>
                                    <Text style={this.state.activeService[2]?styles.activeText:styles.notActiveText}>快递柜取并送至业主家中</Text>
                                </TouchableOpacity>
                            </View>
                        </View>
                    </View>
                    <View style={styles.formContainer}>
                        <View style={styles.formItem}>
                            <Text style={styles.leftText}>服务时间</Text>

                            <DatePicker
                                style={styles.centeDate}
                                date={this.state.date}
                                mode="datetime"
                                format="YYYY-MM-DD HH:mm"
                                minDate={moment().format('YYYY-MM-DD HH:mm')}
                                // maxDate="2016-06-01"
                                confirmBtnText="确定"
                                cancelBtnText="关闭"
                                showIcon={false}
                                customStyles={{
                                  dateInput: {
                                    marginLeft: 0,
                                    alignItems: 'flex-start',
                                    borderWidth:0,
                                    },
                                  dateText:{
                                    textAlign: 'left',
                                },
                                btnTextCancel:{
                                    color: '#7B7B7B',
                                    fontSize: 15,
                                },
                                btnTextConfirm:{
                                    color: '#EA5404',
                                    fontSize:15
                                },
                                datePicker:{
                                    borderTopColor: '#DDDDDD',
                                    backgroundColor: '#fff',
                                },
                                datePickerCon:{
                                    backgroundColor: '#f3f3f3',
                                }
                                }}
                                onDateChange={
                                    (date) => {this.setState({date: date})
                                    if (this.state.send_phone && this.state.send_phone.length == 11) {
                                        this._getServiceFeeInfo(this.state.send_phone,date)
                                    }
                                }}
                              />
                        </View>
                        
                        {
                            isPay && serviceFee && serviceFee.length > 0?
                            serviceFee.map((item,index) =>{
                                return (<TouchableOpacity key={index} style={[styles.addressBtnTime,{borderBottomWidth: StyleSheet.hairlineWidth,
        borderColor: '#DDDDDD'}]} onPress={this._serviceFeeExplain.bind(this,item)}>
                                    <Text style={styles.leftText}>{item.serviceFeeName}</Text>

                                    {
                                        item.feeModifiable == 1?
                                            <View
                                                style={{flex:1,flexDirection:'row',alignItems:'center',marginLeft: 15}} 
                                            >
                                                <Text style={{color:'#000000',fontSize:15}}>¥</Text>
                                                <TextInput 
                                                    style={{color:'#000000',fontSize:15,flex:1,marginLeft: -3}}
                                                    underlineColorAndroid={'#ffffff'} 
                                                    value={`${item.fee}`}
                                                    clearButtonMode={'while-editing'}
                                                    keyboardType={'numeric'}
                                                    maxLength={10}
                                                    onChangeText={(value)=>{this.onChangeTextMoney(value,item,index)}}/>
                                            </View>
                                        :
                                            <Text style={styles.itemRight}>¥{parseFloat(item.fee).toFixed(2)}</Text>
                                    }

                                    <Text style={styles.nightFeeInstruction}>费用说明</Text>
                                    <Image source={require('../../../img/hk_arrow_icon.png')} style={styles.rightImage}/>
                                </TouchableOpacity>)
                            })
                            :
                            null
                        }
                        

                        <View style={[styles.formItemRemark,{borderBottomWidth:0.5}]}>
                            <Text style={[styles.leftText,{marginTop:10}]}
                            >备注信息</Text>
                            <TextInput
                                value={this.state.remarks}
                                defaultValue={source=='edit'?data.remarks:''}

                                onChangeText={(text) =>{this.setState({remarks:text})}}
                                style={[styles.itemRight,{height:88}]}

                                editable = {true}
                                multiline={Platform.OS=='ios'?false:true}
                                numberOfLines={4}
                                clearButtonMode={'while-editing'}
                                underlineColorAndroid={'#ffffff'}
                                placeholder={'选填，如快递公司，快递单号等'}
                                placeholderTextColor={'#B5B5B5'}
                                textAlignVertical={'top'} 
                            />
                        </View>

                        <View style={[styles.formItemUpload,{borderBottomWidth:0,marginTop: 10}]}>
                            <View style={{position:'relative'}}>
                                <TouchableOpacity
                                    accessible={true}
                                    activeOpacity={0.7}
                                    onPress={ this._clickImage.bind(this,0)}
                                    disabled={this.state.disableUpload}
                                    style={{marginLeft:10,marginBottom: 10}}
                                >
                                    <View style={styles.formUploadPictureContainer}>
                                        {pictureFileUriList[0]?
                                            <Image source={{uri:pictureFileUriList[0]}} resizeMode="contain" style={{width:50,height:50}}/>
                                            :
                                            <Image source={require('../../../img/upload_picture_add_icon.png')}/>
                                        }
                                    </View>
                                </TouchableOpacity>
                                {pictureFileUriList[0] ? 
                                    <TouchableOpacity
                                        accessible={true}
                                        activeOpacity={0.7}
                                        onPress={ this._clearImage.bind(this,0)}
                                        style={{width:12,height:12,position:'absolute',right:0}}
                                        
                                    >
                                        <Image source={require('../../../img/close_icon.png')} style={{width:12,height:12}}/> 
                                    </TouchableOpacity>
                                    :
                                    null
                                }
                            </View>

                            {pictureFileUriList[0] && pictureFileUriList[0] != ""?
                                <View style={{position:'relative'}}>
                                    <TouchableOpacity
                                        accessible={true}
                                        activeOpacity={0.7}
                                        onPress={ this._clickImage.bind(this,1)}
                                        disabled={this.state.disableUpload}
                                        style={{marginLeft:10,marginBottom: 10}}
                                    >
                                        <View style={styles.formUploadPictureContainer}>
                                            {pictureFileUriList[1]?
                                                <Image source={{uri:pictureFileUriList[1]}} resizeMode="contain" style={{width:50,height:50}}/>
                                                :
                                                <Image source={require('../../../img/upload_picture_add_icon.png')}/>
                                            }
                                        </View>
                                    </TouchableOpacity>
                                    {pictureFileUriList[1] ? 
                                        <TouchableOpacity
                                            accessible={true}
                                            activeOpacity={0.7}
                                            onPress={ this._clearImage.bind(this,1)}
                                            style={{width:12,height:12,position:'absolute',right:0}}
                                            
                                        >
                                            <Image source={require('../../../img/close_icon.png')} style={{width:12,height:12}}/> 
                                        </TouchableOpacity>
                                        :
                                        null
                                    }
                                </View>
                                :
                                null
                            }
                            
                            {pictureFileUriList[1]  && pictureFileUriList[1] != ""?
                                <View style={{position:'relative'}}>
                                    <TouchableOpacity
                                        accessible={true}
                                        activeOpacity={0.7}
                                        onPress={ this._clickImage.bind(this,2)}
                                        disabled={this.state.disableUpload}
                                        style={{marginLeft:10,marginBottom: 10}}
                                    >
                                        <View style={styles.formUploadPictureContainer}>
                                            {pictureFileUriList[2]?
                                                <Image source={{uri:pictureFileUriList[2]}} resizeMode="contain" style={{width:50,height:50}}/>
                                                :
                                                <Image source={require('../../../img/upload_picture_add_icon.png')}/>
                                            }
                                        </View>
                                    </TouchableOpacity>
                                    {pictureFileUriList[2] ? 
                                        <TouchableOpacity
                                            accessible={true}
                                            activeOpacity={0.7}
                                            onPress={ this._clearImage.bind(this,2)}
                                            style={{width:12,height:12,position:'absolute',right:0}}
                                        >
                                            <Image source={require('../../../img/close_icon.png')} style={{width:12,height:12}}/> 
                                        </TouchableOpacity>
                                        :
                                        null
                                    }
                                </View>
                                :
                                null
                            }

                            {pictureFileUriList[2]  && pictureFileUriList[2] != ""?
                                <View style={{position:'relative'}}>
                                    <TouchableOpacity
                                        accessible={true}
                                        activeOpacity={0.7}
                                        onPress={ this._clickImage.bind(this,3)}
                                        disabled={this.state.disableUpload}
                                        style={{marginLeft:10,marginBottom: 10}}
                                    >
                                        <View style={styles.formUploadPictureContainer}>
                                            {pictureFileUriList[3]?
                                                <Image source={{uri:pictureFileUriList[3]}} resizeMode="contain" style={{width:50,height:50}}/>
                                                :
                                                <Image source={require('../../../img/upload_picture_add_icon.png')}/>
                                            }
                                        </View>
                                    </TouchableOpacity>
                                    {pictureFileUriList[3] ? 
                                        <TouchableOpacity
                                            accessible={true}
                                            activeOpacity={0.7}
                                            onPress={ this._clearImage.bind(this,3)}
                                            style={{width:12,height:12,position:'absolute',right:0}}
                                        >
                                            <Image source={require('../../../img/close_icon.png')} style={{width:12,height:12}}/> 
                                        </TouchableOpacity>
                                        :
                                        null
                                    }    
                                </View>
                                :
                                null
                            }

                            {pictureFileUriList[3]  && pictureFileUriList[3] != ""?
                                <View style={{position:'relative'}}>
                                    <TouchableOpacity
                                        accessible={true}
                                        activeOpacity={0.7}
                                        onPress={ this._clickImage.bind(this,4)}
                                        disabled={this.state.disableUpload}
                                        style={{marginLeft:10,marginBottom: 10}}
                                    >
                                        <View style={styles.formUploadPictureContainer}>
                                            {pictureFileUriList[4]?
                                                <Image source={{uri:pictureFileUriList[4]}} resizeMode="contain" style={{width:50,height:50}}/>
                                                :
                                                <Image source={require('../../../img/upload_picture_add_icon.png')}/>
                                            }
                                        </View>
                                    </TouchableOpacity>
                                    {pictureFileUriList[4] ? 
                                        <TouchableOpacity
                                            accessible={true}
                                            activeOpacity={0.7}
                                            onPress={ this._clearImage.bind(this,4)}
                                            style={{width:12,height:12,position:'absolute',right:0}}
                                        >
                                            <Image source={require('../../../img/close_icon.png')} style={{width:12,height:12}}/> 
                                        </TouchableOpacity>
                                        :
                                        null
                                    }
                                </View>
                                :
                                null
                            }

                            {pictureFileUriList[4]  && pictureFileUriList[4] != ""?
                                <View style={{position:'relative'}}>
                                    <TouchableOpacity
                                        accessible={true}
                                        activeOpacity={0.7}
                                        onPress={ this._clickImage.bind(this,5)}
                                        disabled={this.state.disableUpload}
                                        style={{marginLeft:10,marginBottom: 10}}
                                    >
                                        <View style={styles.formUploadPictureContainer}>
                                            {pictureFileUriList[5]?
                                                <Image source={{uri:pictureFileUriList[5]}} resizeMode="contain" style={{width:50,height:50}}/>
                                                :
                                                <Image source={require('../../../img/upload_picture_add_icon.png')}/>
                                            }
                                        </View>
                                    </TouchableOpacity>
                                    {pictureFileUriList[5] ? 
                                        <TouchableOpacity
                                            accessible={true}
                                            activeOpacity={0.7}
                                            onPress={ this._clearImage.bind(this,5)}
                                            style={{width:12,height:12,position:'absolute',right:0}}
                                        >
                                            <Image source={require('../../../img/close_icon.png')} style={{width:12,height:12}}/> 
                                        </TouchableOpacity>
                                        :
                                        null
                                    }
                                </View>
                                :
                                null
                            }

                            {pictureFileUriList[5]  && pictureFileUriList[5] != ""?
                                <View style={{position:'relative'}}>
                                    <TouchableOpacity
                                        accessible={true}
                                        activeOpacity={0.7}
                                        onPress={ this._clickImage.bind(this,6)}
                                        disabled={this.state.disableUpload}
                                        style={{marginLeft:10,marginBottom: 10}}
                                    >
                                        <View style={styles.formUploadPictureContainer}>
                                            {pictureFileUriList[6]?
                                                <Image source={{uri:pictureFileUriList[6]}} resizeMode="contain" style={{width:50,height:50}}/>
                                                :
                                                <Image source={require('../../../img/upload_picture_add_icon.png')}/>
                                            }
                                        </View>
                                    </TouchableOpacity>
                                    {pictureFileUriList[6] ? 
                                        <TouchableOpacity
                                            accessible={true}
                                            activeOpacity={0.7}
                                            onPress={ this._clearImage.bind(this,6)}
                                            style={{width:12,height:12,position:'absolute',right:0}}
                                        >
                                            <Image source={require('../../../img/close_icon.png')} style={{width:12,height:12}}/> 
                                        </TouchableOpacity>
                                        :
                                        null
                                    }
                                </View>
                                :
                                null
                            }

                            {pictureFileUriList[6]  && pictureFileUriList[6] != ""?
                                 <View style={{position:'relative'}}>
                                    <TouchableOpacity
                                        accessible={true}
                                        activeOpacity={0.7}
                                        onPress={ this._clickImage.bind(this,7)}
                                        disabled={this.state.disableUpload}
                                        style={{marginLeft:10,marginBottom: 10}}
                                    >
                                        <View style={styles.formUploadPictureContainer}>
                                            {pictureFileUriList[7]?
                                                <Image source={{uri:pictureFileUriList[7]}} resizeMode="contain" style={{width:50,height:50}}/>
                                                :
                                                <Image source={require('../../../img/upload_picture_add_icon.png')}/>
                                            }
                                        </View>
                                    </TouchableOpacity>
                                    {pictureFileUriList[7] ? 
                                        <TouchableOpacity
                                            accessible={true}
                                            activeOpacity={0.7}
                                            onPress={ this._clearImage.bind(this,7)}
                                            style={{width:12,height:12,position:'absolute',right:0}}
                                        >
                                            <Image source={require('../../../img/close_icon.png')} style={{width:12,height:12}}/> 
                                        </TouchableOpacity>
                                        :
                                        null
                                    }
                                </View>
                                :
                                null
                            }

                            {pictureFileUriList[7]  && pictureFileUriList[6] != ""?
                                <View style={{position:'relative'}}>
                                    <TouchableOpacity
                                        accessible={true}
                                        activeOpacity={0.7}
                                        onPress={ this._clickImage.bind(this,8)}
                                        disabled={this.state.disableUpload}
                                        style={{marginLeft:10,marginBottom: 10}}
                                    >
                                        <View style={styles.formUploadPictureContainer}>
                                            {pictureFileUriList[8]?
                                                <Image source={{uri:pictureFileUriList[8]}} resizeMode="contain" style={{width:50,height:50}}/>
                                                :
                                                <Image source={require('../../../img/upload_picture_add_icon.png')}/>
                                            }
                                        </View>
                                    </TouchableOpacity>
                                    {pictureFileUriList[8] ? 
                                        <TouchableOpacity
                                            accessible={true}
                                            activeOpacity={0.7}
                                            onPress={ this._clearImage.bind(this,8)}
                                            style={{width:12,height:12,position:'absolute',right:0}}
                                        >
                                            <Image source={require('../../../img/close_icon.png')} style={{width:12,height:12}}/> 
                                        </TouchableOpacity>
                                        :
                                        null
                                    }
                                </View>
                                :
                                null
                            }

                            {pictureFileUriList[8]  && pictureFileUriList[8] != ""?
                                <View style={{position:'relative'}}>
                                    <TouchableOpacity
                                        accessible={true}
                                        activeOpacity={0.7}
                                        onPress={ this._clickImage.bind(this,9)}
                                        disabled={this.state.disableUpload}
                                        style={{marginLeft:10,marginBottom: 10}}
                                    >
                                        <View style={styles.formUploadPictureContainer}>
                                            {pictureFileUriList[9]?
                                                <Image source={{uri:pictureFileUriList[9]}} resizeMode="contain" style={{width:50,height:50}}/>
                                                :
                                                <Image source={require('../../../img/upload_picture_add_icon.png')}/>
                                            }
                                        </View>
                                    </TouchableOpacity>
                                    {pictureFileUriList[9] ? 
                                        <TouchableOpacity
                                            accessible={true}
                                            activeOpacity={0.7}
                                            onPress={ this._clearImage.bind(this,9)}
                                            style={{width:12,height:12,position:'absolute',right:0}}
                                        >
                                            <Image source={require('../../../img/close_icon.png')} style={{width:12,height:12}}/> 
                                        </TouchableOpacity>
                                        :
                                        null
                                    }
                                </View>
                                :
                                null
                            }

                            
                        </View>
                    </View>
                </KeyboardAwareScrollView>
                <View style={styles.submitBtnContainer}>
                    <Touch onPress={this._getNonPayment.bind(this)} style={styles.submitBtn}>
                        <Text style={styles.submitBtnText}>确定</Text>
                    </Touch>
                </View>
                <ToastTip ref="toast" offsetY={160}/>
                <LoadingTip show={this.state.loadingShow}/>
            </View>
        );
    }
}

var connectHelper = require('../../services/connectHelper');
EditExpressOrder = connectHelper(state => state)(EditExpressOrder);

module.exports = EditExpressOrder;
